module.exports = (req,res,next)=>{
    // console.dir(req.session)
    // console.log(req.url)
    if(req.url != '/login' && !req.session.username){
        res.redirect('/admin/login')
    }else{
        if(req.session.role == 0){
            return res.redirect('/home')
        }
        next()
    }
    
}